<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorator="themes/default/layout/public">

<head>
    <title th:text="|专家认证 - ${GlobalSetting.website.name}|"></title>
    <link th:href="@{/static/js/select2/css/select2.min.css}" rel="stylesheet"/>
    <link th:href="@{/static/js/select2/css/select2-bootstrap.min.css}" rel="stylesheet"/>
    <script th:src="@{/static/js/select2/js/select2.min.js}"></script>
    <script type="text/javascript">
        $(function(){
            $("#select_tags").select2({
                theme:'bootstrap',
                placeholder: "认证领域，例如法律、互联网、电脑等不超过5个词语",
                ajax: {
                    url: '/ajax/loadTags',
                    dataType: 'json',
                    delay: 250,
                    data: function (params) {
                        return {
                            word: params.term
                        };
                    },
                    processResults: function (data) {
                        return {
                            results: data
                        };
                    },
                    cache: true
                },
                minimumInputLength:1,
                tags:true
            });

            /*加载省份城市*/
            $("#province").change(function(){
                var province_id = $(this).val();
                $("#city").load("/common/loadCities/"+province_id);
            });

            $("#select_tags").change(function(){
                $("#tags").val($("#select_tags").val());
            });


        });
    </script>
</head>
<div  layout:fragment="content">
    <div class="row">
        <!--左侧菜单-->
        <div th:replace="themes/default/layout/profile_menu"></div>

        <div id="main" class="settings col-md-10 form-horizontal">
            <h2 class="h3 post-title">专家认证</h2>
            <th:block th:if="${authentication}">
            <div th:if="${authentication.status==0}" class="alert alert-info" role="alert">
                您的申请提交成功！我们会在三个工作日内处理，处理结果会通过邮件、站内消息方式通知您，如有疑问请联系官方管理员。
            </div>
            <div th:if="${authentication.status==1}" class="alert alert-success" role="alert">
                恭喜，您的认证申请已通过审核！
            </div>
            <div th:if="${authentication.status==2}" class="alert alert-danger" role="alert">
                抱歉，经过我们的审核您提交的资料未通过审核，请核实一下资料信息,再次提交。
                失败原因：<th:block th:text="${authentication.failedReason}"/>
            </div>
            </th:block>
            <div class="row mt-30">
                <div class="col-md-8">
                    <div th:if="${authentication!=null && !edit}" class="box box-solid">
                        <div class="box-body col-md-6"  >
                            <dl class="dl-horizontal">
                                <dt>真实姓名</dt>
                                <dd th:text="${authentication.realName}"></dd>
                                <dt>性别</dt>
                                <dd th:text="${authentication.gender.name}"></dd>
                                <dt>所在城市</dt>
                                <dd th:text="|${authentication.province.name}${authentication.city.name}|"></dd>
                                <dt>职业身份</dt>
                                <dd th:text="${authentication.title}"></dd>
                                <dt>个人简介</dt>
                                <dd th:text="${authentication.description}"></dd>
                            </dl>

                        </div>

                        <div class="box-body col-md-6" >
                            <dl class="dl-horizontal">
                                <dt>身份照号码</dt>
                                <dd th:text="${authentication.idCard}"></dd>
                                <dt>身份照正面照片</dt>
                                <dd><img class="img-responsive" th:src="${authentication.idCardImage}" /></dd>
                                <dt>认证领域</dt>
                                <dd th:text="${authentication.category.name}"></dd>
                                <dt>认证标签</dt>
                                <dd th:text="${authentication.tagNames}"></dd>
                                <dt>专业性证明文件</dt>
                                <dd><img class="img-responsive" th:src="${authentication.skillImage}" /></dd>
                            </dl>

                        </div>

                        <div style="text-align: center;"><a href="/profile/authentication/edit" class="btn btn-warning">修改认证资料</a></div>
                    </div>
                    <form th:if="${authentication==null || edit==true}" name="authForm" id="authentication_form" enctype="multipart/form-data" th:action="@{/profile/authentication}" method="POST">
                        <input type="hidden" id="tagNames" name="tagNames" th:value="${dto.tagNames}" />
                        <div class="form-group" th:classappend="${error.fields['realName']!=null}?'has-error'">
                            <label class="control-label col-sm-3 required">真实姓名</label>
                            <div class="col-sm-9">
                                <input name="realName" type="text" maxlength="32" placeholder="真实姓名" class="form-control" th:value="${dto.realName}" />
                                <span class="help-block" th:if="${error.fields['realName']!=null}" th:text="${error.fields['realName']}" ></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-3">性别</label>
                            <div class="col-sm-9">
                                <label th:if="${state.index>0}" th:each="gender,state:${AllUserGender}" class="radio-inline"><input name="gender" type="radio" th:text="${gender.name}" th:value="${gender}" th:checked="${dto.gender == gender || (dto.gender==null && currentUser.detail.gender==gender)}"></label>
                            </div>
                        </div>

                        <div class="form-group" th:classappend="${error.fields['province']!=null || error.fields['city']!=null}?'has-error'" onclick="$(this).removeClass('has-error');$(this).children().removeClass('has-error');$(this).find('.help-block').remove()">
                            <label class="control-label col-sm-3">所在城市</label>
                            <div class="col-sm-4" th:classappend="${error.fields['province']!=null}?'has-error'">
                                <select class="form-control" name="province" id="province">
                                    <option value="">请选择省份</option>
                                    <option th:each="province:${AllProvince}" th:attr="provinceId=${province.id}" th:value="${province.id}" th:text="${province.name}" th:selected="${dto?.province == province}"> </option>
                                </select>
                                <span class="help-block" th:if="${error.fields['province']!=null}" th:text="${error.fields['province']}" ></span>
                            </div>
                            <div class="col-sm-5" th:classappend="${error.fields['city']!=null}?'has-error'">
                                <select class="form-control" name="city" id="city">
                                    <option value="">请选择城市</option>
                                    <option th:each="city:${dto.province?.childs}"  th:value="${city.id}" th:text="${city.name}" th:selected="${dto.city == city}" ></option>
                                </select>
                                <span class="help-block" th:if="${error.fields['city']!=null}" th:text="${error.fields['city']}" ></span>
                            </div>


                        </div>

                        <div class="form-group" th:classappend="${error.fields['title']!=null}?'has-error'">
                            <label class="control-label col-sm-3">身份职业</label>
                            <div class="col-sm-9">
                                <input name="title" id="title" type="text" maxlength="32" placeholder="例如：汽车制造 / 产品设计师 / 登山爱好者" class="form-control" th:value="${dto.title}" />
                                <span class="help-block" th:if="${error.fields['title']!=null}" th:text="${error.fields['title']}" ></span>
                            </div>
                        </div>

                        <div class="form-group" th:classappend="${error.fields['description']!=null}?'has-error'">
                            <label for="setting-description" class="control-label col-sm-3">自我介绍</label>
                            <div class="col-sm-9">
                                <textarea name="description" id="setting-description" class="form-control" rows="6" th:text="${dto.description}"></textarea>
                                <span class="help-block" th:if="${error.fields['description']!=null}" th:text="${error.fields['description']}" ></span>
                            </div>
                        </div>

                        <div class="form-group" th:classappend="${error.fields['idCard']!=null}?'has-error'">
                            <label class="control-label col-sm-3 required">身份照号码</label>
                            <div class="col-sm-9">
                                <input name="idCard" type="text" maxlength="32" placeholder="身份照号码" class="form-control" th:value="${dto.idCard}" />
                                <span class="help-block" th:if="${error.fields['idCard']!=null}" th:text="${error.fields['idCard']}" ></span>
                            </div>
                        </div>
                        <div class="form-group" th:classappend="${error.fields['idCardImage']!=null}?'has-error'">
                            <label id="id_card_image" class="control-label col-sm-3 required">身份照正面照片</label>
                            <div class="col-sm-9">
                                <input  class="form-control" type="file" name="idCardImage" />
                                <span class="help-block" th:if="${error.fields['idCardImage']!=null}" th:text="${error.fields['idCardImage']}" ></span>
                                <div th:if="${error.fields['idCardImage']==null}" class="help-block">
                                    1.请上传身份证正面带有头像的扫描件或清晰照片<br />
                                    2.照片要求格式为JPG/JPEG/GIF/PNG，大小不要超过2M
                                </div>
                            </div>
                        </div>
                        <div class="form-group" th:classappend="${error.fields['categoryId']!=null}?'has-error'">
                            <label class="control-label col-sm-3 required">认证领域</label>
                            <div class="col-sm-9">
                                <select name="categoryId" id="categoryId" class="form-control">
                                    <option value="0">请选择分类</option>
                                    <option th:each="category:${categorys}" th:value="${category.id}" th:text="${category.name}" th:selected="${category.id == dto.categoryId}"></option>
                                </select>
                                <p class="help-block" th:if="${error.fields['categoryId']!=null}" th:text="${error.fields['categoryId']}"></p>
                            </div>
                        </div>
                        <div class="form-group" th:classappend="${error.fields['tagNames']!=null}?'has-error'">
                            <label for="select_tags" class="control-label col-sm-3 required">认证标签</label>
                            <div class="col-sm-9">
                                <select id="select_tags" name="select_tags" class="form-control" multiple="multiple" >
                                    <option th:each="tag:${dto.tags}" th:value="${tag.name}"  selected th:text="${tag.name}"></option>
                                </select>
                                <span class="help-block" th:if="${error.fields['tagNames']!=null}" th:text="${error.fields['tagNames']}" ></span>
                            </div>
                        </div>



                        <div class="form-group" th:classappend="${error.fields['skillImage']!=null}?'has-error'">
                            <label id="skill_image" class="control-label col-sm-3 required">专业性证明</label>
                            <div class="col-sm-9">
                                <input  class="form-control" type="file" name="skillImage" />
                                <span class="help-block" th:if="${error.fields['skillImage']!=null}" th:text="${error.fields['skillImage']}" ></span>
                                <div th:if="${error.fields['skillImage']==null}" class="help-block">
                                    1.请上传您的工卡、单位证明、资格证书、获奖证书等一切可证明您身份的材料照片<br />
                                    2.照片要求格式为JPG/JPEG/GIF/PNG，大小不要超过2M
                                </div>
                            </div>
                        </div>
                        <div class="form-group" th:classappend="${error.fields['imageCode']!=null}?'has-error'">
                            <label for="captcha" class="required control-label col-sm-3">验证码</label>
                            <div class="col-sm-4">
                                <input id="captcha" name="captcha" type="text" maxlength="32" placeholder="请输入下方验证码" class="form-control" th:value="${imageCode}" />
                                <span class="help-block" th:if="${error.fields['imageCode']!=null}" th:text="${error.fields['imageCode']}" ></span>
                                <div class="mt-10"><a href="javascript:void(0);" id="reloadCaptcha"><img th:src="${GlobalSetting.irrigation.codeUrl}"></a></div>
                            </div>
                        </div>

                        <div class="form-action row">
                            <div class="col-sm-offset-3 col-sm-9">
                                <button class="btn btn-xl btn-primary profile-sub" type="submit">提交申请</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>